﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace PedesTrainProject.Grid
{
    [Serializable()]
    public class Slot : ISerializable
    {
        private bool lights;

        public bool Lights
        {
            get { return lights; }
            set { lights = value; }
        }
        private bool car_access;

        public bool Car_access
        {
            get { return car_access; }
            set { car_access = value; }
        }
        private bool pedestrian_access;

        public Slot()
        {
        }
        public Slot (bool _car_access, bool _pedestrian_access, bool _lights)
        {
            car_access = _car_access;
            pedestrian_access = _pedestrian_access;
            lights = _lights;
        }

        public void switchAccess()
        {
            if (car_access == true)
            {
                car_access = false;
                pedestrian_access = true;
            }
            else
            {
                car_access = true;
                pedestrian_access = false;
            }
        }
        #region Serialize
        public Slot(SerializationInfo info, StreamingContext ctxt)
        {
            this.lights = (bool)info.GetValue("Lights", typeof(bool));
            this.car_access = (bool)info.GetValue("Car_Access", typeof(bool));
            this.pedestrian_access = (bool)info.GetValue("Pedestrian_Access", typeof(bool));
        }

        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            info.AddValue("Lights", this.lights);
            info.AddValue("Car_Access", this.car_access);
            info.AddValue("Pedestrian_Access", this.pedestrian_access);
        }
        #endregion
    }
    
}

